﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DEMO3.DTO;
using System.Data.SqlClient;
using System.Data;
namespace DEMO3.DAO
{
    class SuatChieuDAO
    {
        public DataTable Get()
        {
            DataProvider test = new DataProvider();
            return test.ExcuteQuery("GET_SUATCHIEU", null);
        }

        public bool Add(SuatChieuDTO dto)
        {
            DataProvider test = new DataProvider();
            SqlParameter[] arrpara = new SqlParameter[4];
            arrpara[0] = new SqlParameter("MaPhim", dto.MaPhim);
            arrpara[1] = new SqlParameter("MaPhong", dto.MaPhong);
            arrpara[2] = new SqlParameter("MaCaChieu", dto.MaCaChieu);
            arrpara[3] = new SqlParameter("GiaVe", dto.GiaVe);
            return test.ExcuteNonQuery("ADD_SUATCHIEU", arrpara);
        }
        public bool Delete(SuatChieuDTO dto)
        {
            DataProvider test = new DataProvider();
            SqlParameter[] arrpara = new SqlParameter[1];
            arrpara[0] = new SqlParameter("MaSuatChieu", dto.MaSuatChieu);
            return test.ExcuteNonQuery("DELETE_SUATCHIEU", arrpara);
        }
        public bool Update(SuatChieuDTO dto)
        {
            DataProvider test = new DataProvider();
            SqlParameter[] arrpara = new SqlParameter[5];
            arrpara[0] = new SqlParameter("MaSuatChieu", dto.MaSuatChieu);
            arrpara[1] = new SqlParameter("MaPhim", dto.MaPhim);
            arrpara[2] = new SqlParameter("MaPhong", dto.MaPhong);
            arrpara[3] = new SqlParameter("MaCaChieu", dto.MaCaChieu);
            arrpara[4] = new SqlParameter("GiaVe", dto.GiaVe);
            return test.ExcuteNonQuery("UPDATE_SUATCHIEU", arrpara);
        }
    }
}
